<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    sajdfkljasdklfjasdl
    asjkdlfjasdkl;fja
    kasldfjkasl;djf
    asjkfjasdk;lfjasd
    ajksldfjaksld;fjas
    kjlasdfjk;ldasjf
    jkalsdjflk;asf
    sajdfkljasdklfjasdl
    asjkdlfjasdkl;fja
    kasldfjkasl;djf
    asjkfjasdk;lfjasd
    ajksldfjaksld;fjas
    kjlasdfjk;ldasjf
    jkalsdjflk;asf
    sajdfkljasdklfjasdl
    asjkdlfjasdkl;fja
    kasldfjkasl;djf
    asjkfjasdk;lfjasd
    ajksldfjaksld;fjas
    kjlasdfjk;ldasjf
    jkalsdjflk;asf
    sajdfkljasdklfjasdl
    asjkdlfjasdkl;fja
    kasldfjkasl;djf
    asjkfjasdk;lfjasd
    ajksldfjaksld;fjas
    kjlasdfjk;ldasjf
    jkalsdjflk;asf
    sajdfkljasdklfjasdl
    asjkdlfjasdkl;fja
    kasldfjkasl;djf
    asjkfjasdk;lfjasd
    ajksldfjaksld;fjas
    kjlasdfjk;ldasjf
    jkalsdjflk;asf
    sajdfkljasdklfjasdl
    asjkdlfjasdkl;fja
    kasldfjkasl;djf
    asjkfjasdk;lfjasd
    ajksldfjaksld;fjas
    kjlasdfjk;ldasjf
    jkalsdjflk;asf
    sajdfkljasdklfjasdl
    asjkdlfjasdkl;fja
    kasldfjkasl;djf
    asjkfjasdk;lfjasd
    ajksldfjaksld;fjas
    kjlasdfjk;ldasjf
    jkalsdjflk;asf
    sajdfkljasdklfjasdl
    asjkdlfjasdkl;fja
    kasldfjkasl;djf
    asjkfjasdk;lfjasd
    ajksldfjaksld;fjas
    kjlasdfjk;ldasjf
    jkalsdjflk;asf
    sajdfkljasdklfjasdl
    asjkdlfjasdkl;fja
    kasldfjkasl;djf
    asjkfjasdk;lfjasd
    ajksldfjaksld;fjas
    kjlasdfjk;ldasjf
    jkalsdjflk;asf
    sajdfkljasdklfjasdl
    asjkdlfjasdkl;fja
    kasldfjkasl;djf
    asjkfjasdk;lfjasd
    ajksldfjaksld;fjas
    kjlasdfjk;ldasjf
    jkalsdjflk;asf
    sajdfkljasdklfjasdl
    asjkdlfjasdkl;fja
    kasldfjkasl;djf
    asjkfjasdk;lfjasd
    ajksldfjaksld;fjas
    kjlasdfjk;ldasjf
    jkalsdjflk;asf
    sajdfkljasdklfjasdl
    asjkdlfjasdkl;fja
    kasldfjkasl;djf
    asjkfjasdk;lfjasd
    ajksldfjaksld;fjas
    kjlasdfjk;ldasjf
    jkalsdjflk;asf
    sajdfkljasdklfjasdl
    asjkdlfjasdkl;fja
    kasldfjkasl;djf
    asjkfjasdk;lfjasd
    ajksldfjaksld;fjas
    kjlasdfjk;ldasjf
    jkalsdjflk;asf
    sajdfkljasdklfjasdl
    asjkdlfjasdkl;fja
    kasldfjkasl;djf
    asjkfjasdk;lfjasd
    ajksldfjaksld;fjas
    kjlasdfjk;ldasjf
    jkalsdjflk;asf
    <button>回到顶部</button>
    <script>
        /**
         * html: document.documentElement
         * 
         * body: document.body
         * 
         */
        console.log(document.documentElement.clientHeight);
        console.log(document.body.clientHeight);

        function Win(attr, value){
            if(typeof value === 'undefined'){ // 说明没有传value参数，那么Win函数的功能就是读取可视区相关属性的值
                return document.documentElement[attr] || document.body[attr];
            }
            // 设置浏览器盒模型相关的值
            document.documentElement[attr] = value;
            document.body[attr] = value;
        }
        console.log(Win('clientHeight'));

        // 获取button按钮
        var oBtn = document.querySelector('button');
        oBtn.onclick = function(){
            Win('scrollTop', '0px');
        }



    </script>
</body>
</html>